<?php
namespace Common\Model;

/**
 * 微预定推送信息关联表
 * @modify wenhui 2017-03-16 创建
 * 
 */

Class HotelNewspushRecordModel extends \Common\Model\BaseModel
{
    protected $trueTableName = 'bk_hotel_newspush_record';
    protected function _before_update(&$data, $options) {
    }
    protected function _before_insert(&$data, $options) {
    }
    /**
     * 添加数据
     * @modify wenhui 2017-03-16 创建
     * @param  array   $pushListItem   新增数据数组
     * @param  int   $userId   操作用户
     * @return boolean 执行结果
     */
    public function addNewsHistory($newsPushId, $type, $userId, $channel, $name) {

        $data = array(
            'hotelnewspush_id' => $newsPushId,
            'creatorstep' => $type,
            'operator' => $userId,
            'channel' => $channel,
            'name' => $name,
        );
        $data['updatetime'] = date('Y-m-d H:i:s');

        return $this->add($data) ? true : false;
    }

    /**
     * 获取数据
     * @modify wenhui 2017-03-16 创建
     * @param  integer   $newsId   bk_hotel_newspush.id  
     * @return array $data 执行结果
     */
    public function getNewsHistoryByNewsId($newsId = null) {

        $option['isdelete'] = 0;
        if (!is_null($newsId)) {
            $option['hotelnewspush_id'] = $newsId;
        }

        $data = $this->where($option)->select();

        return empty($data) ? array() : $data;
    }
   
    /**
     * 根据客栈id获取数据 
     * @modify wenhui 2017-03-16 创建
     * @param  array   $pushList   修改的数据
     * @return bool    
     */
    public function saveNews($pushList) {

        $option['id'] = $pushList['newsPushRelateId'];

        if ($pushList['type'] == 1) {
            $data['newstype'] = 1;
        } else {
            $data['isdelete'] = 1;
        }

        $data['updatetime'] = date('Y-m-d H:i:s');

        return $this->where($option)->save($data) ? true : false;
    }
  

    /**
     * 根据客栈ID 房间ID 获取数据
     * @modify wenhui 2017-03-16          创建
     * @param  integer   $hotelId          客栈ID
     * @param  array   $roomId   房间ID
     * @return boolean 执行结果
     */

}
